/**
 * Created by Administrator on 2018/3/26.
 */
(function(w){

    var events = {};

    //{
    //    'fanshule':[function,function],
    //    'gongjiao':[function,function]
    //}

    function emit(name){//触发事件
        //console.log("參數如下",arguments);
        //arguments.slice(1)
       var args= Array.prototype.slice.apply(arguments,[1]);
        for(var i in events[name]) {
            events[name][i].apply(w, args);
        }
    }

    function on(name,cb){//绑定事件的处理函数
        events[name]||(events[name]=[]);
        events[name].push(cb);
    }

    w.$E={
        emit:emit,
        on:on
    }
})(window);

//$E.on('fanshule',function(a,b){
//    alert("飯熟了"+a);
//});
//
//$E.emit('fanshule',18,22,22);